unit DalLogin;

interface

uses
  DatLogin, Func;

Type
  TDalLogin = class(TDatLogin)
  private
    { private declarations }

  protected
  { protected declarations }
    const
    Table = 'usuarios';
  public
    { public declarations }
    function logar(value: TDatLogin): Boolean;
    constructor Created;
  end;

var
    clsFunc:TFunc;

implementation

uses
  Data.SqlExpr, System.SysUtils;

{ TDalLogin }

constructor TDalLogin.Created;
begin
  clsFunc := TFunc.Create;
end;

function TDalLogin.logar(value: TDatLogin): Boolean;
var
  sqlLogin: TsqlQuery;
begin
  try
    sqlLogin := clsFunc.query('SELECT * FROM usuarios WHERE nome = "' + value.usuario +
      '" AND senha = "' + value.senha + '"');
    sqlLogin.FieldByName('nome_usuario').Text;
    if (sqlLogin.RecordCount > 0) then
    begin
      Result := true;
    end
    else
    begin
      Result := False;
    end;
  except
    on E: Exception do
    Result := False;
  end;
end;

end.
